home *** CD-ROM | disk | FTP | other *** search
- /* Cancel.c: Cancel applet for ProjectDrag.
- *
- * A set of applets for drag and drop source control by Tim Maroney.
- * See develop, issue 23 for details.
- *
- * Built on DropShell by Leonard Rosenthol, Stephan Somogyi, and Marshall Clow,
- * and using the MoreFiles utilities by Jim Luther.
- *
- * This software is free, but don't modify and redistribute it without
- * changing the status window to indicate your name and your changes!
- */
-
-
- #include "DSUserProcs.h"
- #include "PDDialogs.h"
- #include "PDUtilities.h"
- #include "FileCancel.h"
- #include "TasksAndErrors.h"
-
-
- void CancelFile(FSSpec *file, Boolean doingFolder);
-
-
- /* This routine is called for each file passed in the ODOC event. */
-
- pascal void OpenDoc ( FSSpecPtr myFSSPtr, Boolean opening, Handle userDataHandle )
- {
- #pragma unused ( opening )
- #pragma unused ( userDataHandle )
-
- ProcessFileOrFolder(myFSSPtr, CancelFile, ProcessFolder);
- }
-
-
- void CancelFile(FSSpec *file, Boolean doingFolder)
- {
- OSErr err;
- CKIDHandle theCKID;
-
- /* get the CKID */
- TaskStart(2001, 2, file->name, NULL, NULL, NULL); /* inspecting */
- err = ExtractCKID(file, &theCKID);
- if (err != noErr)
- {
- if (!doingFolder)
- RaiseErrorString(kProjectDragStrings, kCantGetCKID, file->name,
- NULL, NULL, NULL);
- return;
- }
- TaskDone();
-
- TaskStart(2001, 1, file->name, NULL, NULL, NULL); /* canceling */
-
- /* is the file already checked out or MRO? */
- if ((*theCKID)->modifyReadOnly || (*theCKID)->writeable)
- {
- /* confirm the discard */
- if (!ResTextYesNo(kProjectDragStrings, kConfirmDiscardChanges, file->name, NULL, NULL, NULL))
- {
- DisposeHandle((Handle)theCKID);
- RaiseErrorNumber(userCanceledErr);
- return;
- }
- }
- else if (!doingFolder)
- {
- /* it doesn't seem to be checked out, but we can try to cancel it anyway
- * -- after all, we may have lost the checked-out copy...
- */
- if (!ResTextYesNo(kProjectDragStrings, kCancelEvenThoughNotCheckedOut, file->name, NULL, NULL, NULL))
- {
- DisposeHandle((Handle)theCKID);
- RaiseErrorNumber(userCanceledErr);
- return;
- }
- }
-
- err = FileCancel(file, theCKID);
- DisposeHandle((Handle)theCKID);
- if (err == noErr) TaskDone();
- }
-
-
- void DoFileMenu(short itemID)
- {
- if ( itemID == 1 )
- SelectFile(); // call file selection userProc
- else
- SendQuitToSelf(); // send self a 'quit' event
- }
-